package com.edu.exam.entity.personnel.student;

import com.edu.exam.enums.student.ChangeStatus;
import com.edu.exam.enums.student.EnrollmentChangeType;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;

/**
 * 学籍异动申请实体类
 * [所属模块] F-04 学籍管理模块
 * 对应数据库表：enrollment_change_application
 */
@Entity
@Table(name = "enrollment_change_application")
public class EnrollmentChangeApplication {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank(message = "申请编号不能为空")
    @Size(max = 50, message = "申请编号长度不能超过50个字符")
    @Column(name = "application_number", unique = true, nullable = false, length = 50)
    private String applicationNumber;

    @NotNull(message = "学籍ID不能为空")
    @Column(name = "enrollment_id", nullable = false)
    private Long enrollmentId;

    @NotNull(message = "异动类型不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "change_type", nullable = false, length = 50)
    private EnrollmentChangeType changeType;

    @NotBlank(message = "申请原因不能为空")
    @Size(max = 1000, message = "申请原因长度不能超过1000个字符")
    @Column(name = "reason", nullable = false, length = 1000)
    private String reason;

    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    @NotNull(message = "申请状态不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private ChangeStatus status = ChangeStatus.PENDING;

    @Column(name = "effective_date")
    private LocalDate effectiveDate;

    @Size(max = 1000, message = "备注信息长度不能超过1000个字符")
    @Column(name = "remarks", length = 1000)
    private String remarks;

    @NotBlank(message = "申请人不能为空")
    @Size(max = 100, message = "申请人长度不能超过100个字符")
    @Column(name = "applicant", nullable = false, length = 100)
    private String applicant;

    @Size(max = 50, message = "申请人与学生关系长度不能超过50个字符")
    @Column(name = "applicant_relationship", length = 50)
    private String applicantRelationship;

    @Column(name = "deleted", nullable = false)
    private Boolean deleted = false;

    @Column(name = "version", nullable = false)
    private Integer version = 0;

    @Column(name = "created_time", nullable = false, updatable = false)
    private java.time.LocalDateTime createdTime;

    @Column(name = "updated_time", nullable = false)
    private java.time.LocalDateTime updatedTime;

    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @Column(name = "created_by", length = 50)
    private String createdBy;

    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @Column(name = "updated_by", length = 50)
    private String updatedBy;
}